﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SundayWishModel.Entities;
using SundayWishBLL;
public partial class publicdishlist : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataBind();
        }
    }
        private void DataBind()
    {
        PublicDishHelper pdh = new PublicDishHelper();
        gvPlanlist.DataSource = pdh.GetDish();
        gvPlanlist.DataBind();
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("btnAddToPrivate"))
        {
            if (Session["user"] == null) Response.Redirect("~/login.aspx");
            else
            {
                UserInfo user=(UserInfo)Session["user"];
                int DishId = Convert.ToInt32(e.CommandArgument);
                PrivateDishHelper pdh = new PrivateDishHelper();
                pdh.AddToPrivate(DishId, user.UserId);
                WebHelper.AlertMsg("aa","添加成功");
            }
        }
        if (e.CommandName.Equals("btnDetail"))
        {
            int DishId = Convert.ToInt32(e.CommandArgument);
            Session["DishId"] = DishId;
            Response.Redirect("publicdish/"+DishId.ToString());
        }
        DataBind();
    }
}
